<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" lang="zh" xmlns:th="http://www.thymeleaf.org" style="height: 100%">
<body class="body_hei edit">
<style>
    .layui-form-item{border: none !important;background: none !important;}
</style>
<div th:replace="include/head.html::html"></div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">基本资料</div>
                <div class="layui-card-body" pad15="">
                    <div class="layui-form" lay-filter="">

                        <div class="layui-form-item">
                            <label class="layui-form-label">登录账号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="account" disabled lay-verify="required" readonly placeholder="请输入登录账号" autocomplete="off" class="layui-input" th:value="${user.account}" >
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="name" lay-verify="required" placeholder="请输入用户名"
                                       autocomplete="off" class="layui-input" th:value="${user.name}" >
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">头像</label>
                            <div class="layui-input-inline" style="margin:0" id="editimg">
                                <img img-type="qiniu" src="work/img/img_loading.gif" th:src="${user.head}" id="srcimgurl" class="layui-upload-img">
                                <input type="hidden" name="head" th:field="${user.head}" id="inputimgurl"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <input class="layui-btn" type="button" lay-submit lay-filter="submit" id="submit" value="确认">
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
<script th:inline="javascript">
    layui.use(['jquery','layer', 'form', 'upload', 'layedit', 'croppers'], function () {
        var $ = layui.$
            , form = layui.form;
        var croppers = layui.croppers;
        //创建一个头像上传组件
        croppers.render({
            elem: '#editimg'
            , saveW: 150     //保存宽度
            , saveH: 150
            , mark: 1 / 1    //选取比例
            , area: '900px'  //弹窗宽度
            , textTip:"头像的尺寸限定200*200px,大小在50kb以内"
            , url: "common/uploadFile"  //图片上传接口返回和（layui 的upload 模块）返回的JOSN一样
            , done: function (url) { //上传完毕回调
                $("#inputimgurl").val(url);
                $("#srcimgurl").attr('src', url);
            }
        });
        form.on('submit(submit)', function (data) {
            $.post("sysuser/updateUserDate", data.field, function (res) {
                if (res.code === 0) {
                    layer.msg(res.msg);
                } else {
                    layer.msg(res.msg);
                }
            });
        });
    });
</script>
</body>
</html>